<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xxl="4" :xl="6">
            <a-form-item label="名称">
              <a-input placeholder="输入名称/助记号码模糊搜索" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
         
          <a-col :md="4" :sm="12">
            <a-form-item label="编码">
              <a-input placeholder="精准搜索" v-model="queryParam.code"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xxl="4" :xl="6">
            <a-form-item label="医保编码">
              <a-input placeholder="精准搜索" v-model="queryParam.medicalCatalogCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xxl="4" :xl="6">
              <a-form-item label="对照上传">
                <j-dict-select-tag v-model="queryParam.miFlag" dictCode="miFlag_status" />
              </a-form-item>
            </a-col>
             <a-col :xxl="4" :xl="6">
              <a-form-item label="目录对照">
                <j-dict-select-tag v-model="queryParam.hasMiCodeFlag" dictCode="drug_mulu_status" />
              </a-form-item>
            </a-col>
          <a-col :xxl="4" :xl="6">
            <a-form-item label="启用状态">
              <!-- <a-input placeholder="模糊搜索" v-model="queryParam.name"></a-input> -->
              <j-dict-select-tag v-model="queryParam.enabledFlag" dictCode="depart_status" />
            </a-form-item>
          </a-col>
          <a-col :xxl="4" :xl="6">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增（F2）</a-button>
      <a-popconfirm title="确定批量上传对照关系吗?" @confirm="()=> handleUploadGX()" v-if="getConfigStatus('mi')">
        <a-button type="primary" icon="shrink">批量上传对照关系</a-button>
      </a-popconfirm>
      <a-button @click="handleUpload" type="primary" icon="upload"  v-has="'upload:admin'">导入</a-button>
      <a-button @click="handleCatalogAdd" type="warning" icon="diff">医保目录添加</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-dropdown>
              <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
              <a-menu slot="overlay">
                <a-menu-item v-if="record.enabledFlag+'' === '1'">
                  <a-popconfirm title="确定禁用吗?" @confirm="() => handleSetEable(record)">
                    <a>禁用</a>
                  </a-popconfirm>
                </a-menu-item>
                <a-menu-item v-if="record.enabledFlag+'' !== '1'">
                  <a-popconfirm title="确定启用吗?" @confirm="() => handleSetEable(record)">
                    <a>启用</a>
                  </a-popconfirm>
                </a-menu-item>
                <a-menu-item>
                  <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                    <a>删除</a>
                  </a-popconfirm>
                </a-menu-item>
                <a-menu-item>
                  <a @click="handleSetPrice(record)">调价</a>
                </a-menu-item>
                <a-menu-item>
                  <a @click="handleSetCode(record)">重新对码</a>
                </a-menu-item>
                <a-menu-item>
                  <a @click="handleSetTicheng(record)">提成调整</a>
                </a-menu-item>
              </a-menu>
            </a-dropdown>
        </span>

      </a-table>
    </div>
    <setmiCodeModal ref="micodeModal" @ok="handleCatalogOk"></setmiCodeModal>
    <setPriceModal ref="modalPrice" @ok="modalPriceOk"></setPriceModal>
    <service-project-modal ref="modalForm" @ok="modalFormOk"></service-project-modal>
    <uploadModal ref="uploadDom" @ok="modalPriceOk"></uploadModal>
    <setTichengModal ref="TichengDom" @ok="modalPriceOk"></setTichengModal>
    <J-select-biz-component-modal ref="selectModal" v-bind="modalProps"  v-model="selectValue"
        :visible.sync="modalvisible" listUrl="wh/medicalServiceProject/miQueryPage"
        @getv="bizValChange" :columns="gyscolumns"   :pamaName="'keyword'" :queryParamCode="['keyword','code','name','pinyinCode']" :queryParamText="['关键字','编码','名称','助记码']">
      </J-select-biz-component-modal>
  </a-card>
</template>

<script>
import JSelectBizComponentModal from '@/components/jeecgbiz/JSelectBizComponent3/JSelectBizComponentModal'
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ServiceProjectModal from './modules/WhMedicalServiceProjectModal'
  import setPriceModal from './modules/setPriceModal'
  import uploadModal from './modules/uploadModal'
  import { yaodianMinxin } from '@/mixins/yaodianMinxin'
  import setTichengModal from './modules/setTichengModal.vue'
  import setmiCodeModal from './modules/setmiCodeModal.vue'

  import { otherKeyMinxin } from '@/mixins/otherKeyMinxin'
  export default {
    props:['keyIndex'],
    name: 'WhDrugChineseList',
    mixins:[JeecgListMixin, mixinDevice,yaodianMinxin,otherKeyMinxin],
    components: {
      ServiceProjectModal,
      setPriceModal,
      uploadModal,
      JSelectBizComponentModal,
      setTichengModal,
      setmiCodeModal
    },
    data () {
      return {
        description: '药典-中药表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'名称',
            align:"center",
            dataIndex: 'name',
            width:200,
            fixed:'left'
          },
          {
            title:'编码',
            align:"center",
            dataIndex: 'code'
          },
          {
            title:'医保名称',
            align:"center",
            dataIndex: 'medicalCatalogName',
            width:200
          },
          {
            title:'医保编码',
            align:"center",
            dataIndex: 'medicalCatalogCode'
          },
          {
            title:'发票类别',
            align:"center",
            dataIndex: 'projectType_dictText'
          },
          {
            title:'零售价',
            align:"center",
            dataIndex: 'retailPrice'
          },
          {
            title:'单品提成',
            align:"center",
            dataIndex: 'singleCommission'
          },{
            title:'库存数量',
            align:"center",
            dataIndex: 'stockQuantity'
          },
          {
            title:'单位',
            align:"center",
            dataIndex: 'unit'
          },
          {
            title:'收费等级',
            align:"center",
            dataIndex: 'miLevel'
          },
          {
            title:'医保对照上传状态',
            align:"center",
            dataIndex: 'miFlag',
            customRender: function (text) {
              if (text == 1) {
                return '已上传'
              } else {
                return '未上传'
              }
            }
          },
          {
            title:'销售标识',
            align:"center",
            dataIndex: 'saleFlag',
            customRender: function (text) {
              if (text == 1) {
                return '已销售'
              } else {
                return '未销售'
              }
            }
          },
          {
            title:'启用状态',
            align:"center",
            dataIndex: 'enabledFlag_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/wh/medicalServiceProject/list",
          delete: "/wh/medicalServiceProject/delete",
          deleteBatch: "/wh/medicalServiceProject/deleteBatch",
          exportXlsUrl: "/wh/medicalServiceProject/exportXls",
          importExcelUrl: "wh/medicalServiceProject/import",
          switchstate:'wh/medicalServiceProject/switchState',
          miBatchUpload:'wh/medicalServiceProject/miBatchUpload',
          
        },
        dictOptions:{},
        gyscolumns: [
          { title: '医保编码', dataIndex: 'medicalCatalogCode', align: 'center', width: '55%' },
          { title: '医保名称', dataIndex: 'medicalCatalogName', align: 'center', width: '45%' },
          { title: '项目内涵', dataIndex: 'projectConnotation', align: 'center', width: '45%' },
          { title: '项目说明', dataIndex: 'projectDesc', align: 'center', width: '45%' },
          { title: '除外内容', dataIndex: 'exclusionContent', align: 'center', width: '45%' },
          { title: '收费等级', dataIndex: 'miLevel', align: 'center', width: '45%' },
        ],
        codeurls:'wh/medicalServiceProject/recode'
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>